//
//  TabBarViewController.m
//  ManStoreDemo
//
//  Created by qianfeng01 on 15/7/17.
//  Copyright (c) 2015年 xiangmu. All rights reserved.
//

#import "TabBarViewController.h"
#import "WMPageController.h"
#define kScreenSize [UIScreen mainScreen].bounds.size
@interface TabBarViewController ()

@end

@implementation TabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self createViewController];
    
}

-(void)createViewController{
    NSArray *titles=@[@"优惠",@"精选",@"单品",@"我的"];
    NSArray *tabBarVC=@[@"search2",@"favo2",@"item2",@"mine2"];
    NSArray *tabBarHightVC=@[@"search1",@"favo1",@"item1",@"mine1"];
    
    NSMutableArray *Names=[NSMutableArray arrayWithArray:@[@"NineViewController",@"SelectionViewController",@"JacketViewController",@"UserViewController"]];
    
    NSMutableArray *allArr=[[NSMutableArray alloc] init];
    
    //NSMutableArray *allArr=[[NSMutableArray alloc] init];
    NSMutableArray *rlArr=[[NSMutableArray alloc] init];
    
    NSArray *arr=@[@"9块9",@"19块9",@"29块9"];
    NSMutableArray  *rollArr=[NSMutableArray arrayWithArray:@[@"NineViewController",@"NineteenViewController",@"Twenty_nineViewController"]];
    for (int i=0; i<rollArr.count; i++) {
        Class cls=NSClassFromString(rollArr[i]);
        UIViewController *VC=[[cls alloc] init];
        
        [rlArr addObject:VC];
    }
    WMPageController *pc=[[WMPageController alloc] initWithViewControllers:rlArr andTheirTitles:arr];
    UINavigationController *nav1=[[UINavigationController alloc] initWithRootViewController:pc];
    pc.title=titles[0];
    nav1.tabBarItem.title=titles[0];
    nav1.tabBarItem.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",tabBarVC[0]]];
    [nav1.navigationBar setBackgroundImage:[UIImage imageNamed:@"gray_kuang"] forBarMetrics:UIBarMetricsDefault];
    pc.menuItemWidth=kScreenSize.width/3;
    [allArr addObject:nav1];
 
    for (NSInteger i=1; i<Names.count; i++) {
        
            Class cls=NSClassFromString(Names[i]);
            UIViewController *VC=[[cls alloc] init];
            UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:VC];
        if (i==1) {
        VC.title=titles[1];
            //nav.navigationBarHidden=YES;
        }
        if (i==2) {
            VC.title=@"上衣";
        }else{
            VC.title=titles[i];
        }
            nav.tabBarItem.title=titles[i];
            nav.tabBarItem.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",tabBarVC[i]]];
            nav.tabBarItem.selectedImage=[[UIImage imageNamed:[NSString stringWithFormat:@"%@",tabBarHightVC[i]]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
            
            [nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"gray_kuang"] forBarMetrics:UIBarMetricsDefault];
            [allArr addObject:nav];

    }
    self.viewControllers=allArr;
}






@end
